# -*- encoding:utf-8 -*-
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1291609872.608161
_template_filename=u'/Users/joeldunham/old/onlinelinguisticdatabase/templates/base/searchFields.html'
_template_uri=u'/base/searchFields.html'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding='utf-8'
from webhelpers.html import escape
_exports = ['orderBy', 'formSearchFields', 'searchIntegerFilter', 'searchFilter', 'fileSearchFields', 'dictionarySearch', 'searchFiltersFooter', 'additionalFormSearchFilters', 'additionalFileSearchFilters', 'searchFiltersHeader', 'collectionSearchFields', 'searchExpressions', 'searchDateFilter', 'additionalCollectionSearchFilters']


def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        __M_writer = context.writer()
        # SOURCE LINE 5
        __M_writer(u'\n\n\n')
        # SOURCE LINE 12
        __M_writer(u'\n\n\n')
        # SOURCE LINE 19
        __M_writer(u'\n\n\n<!--Search Expressons def-->\n<!--used for searching Forms, Files and Collections-->\n')
        # SOURCE LINE 48
        __M_writer(u'\n\n\n')
        # SOURCE LINE 74
        __M_writer(u'\n\n\n\n')
        # SOURCE LINE 99
        __M_writer(u'\n\n\n')
        # SOURCE LINE 122
        __M_writer(u'\n\n\n')
        # SOURCE LINE 137
        __M_writer(u'\n\n\n')
        # SOURCE LINE 143
        __M_writer(u'\n\n\n<!--searchFilter() def-->\n<!--This def will create filters on speaker, source, etc.--> \n')
        # SOURCE LINE 161
        __M_writer(u'\n\n<!--searchDateFilter() def-->\n<!--This def will create filters on dateElicited, datetimeModified, datetimeEntered, etc.--> \n')
        # SOURCE LINE 172
        __M_writer(u'\n\n\n<!--searchIntegerFilter() def-->\n<!--This def will create filters on integer fields like file.size, file.id, form.id, etc.--> \n')
        # SOURCE LINE 186
        __M_writer(u'\n\n')
        # SOURCE LINE 198
        __M_writer(u'\n\n\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_orderBy(context,columns,selected='id'):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 188
        __M_writer(u'\n<fieldset>\n<legend>Order By</legend>\n<ol>\n <li>\n  ')
        # SOURCE LINE 193
        __M_writer(escape(h.select(name='orderByColumn', selected_values='', options=columns, tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 194
        __M_writer(escape(h.select(name='orderByDirection', selected_values='', options=[('desc', 'descending'), ('asc', 'ascending')], tabindex=8)))
        __M_writer(u'\n </li>\n</ol>\n</fieldset>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_formSearchFields(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n ')
        # SOURCE LINE 2
        __M_writer(escape(self.searchExpressions('form')))
        __M_writer(u'\n ')
        # SOURCE LINE 3
        __M_writer(escape(self.orderBy(app_globals.searchLocations['form'])))
        __M_writer(u'\n ')
        # SOURCE LINE 4
        __M_writer(escape(self.additionalFormSearchFilters()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchIntegerFilter(context,entity,index,units=None):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 177
        __M_writer(u'\n<li>\n  ')
        # SOURCE LINE 179
        __M_writer(escape(h.select(name='integerRestrictors-%s.location'%(index), selected_values='', options=app_globals.searchIntegerFilterLocations[entity], tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 180
        __M_writer(escape(h.select(name='integerRestrictors-%s.relation'%(index), selected_values='', options=[('==', 'is'), ('!=', 'is not'), ('lt', 'is less than'), ('gt', 'is greater than')], tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 181
        __M_writer(escape(h.text(name='integerRestrictors-%s.integer'%(index), size='10', maxlength='10', tabindex=8)))
        __M_writer(u'\n')
        # SOURCE LINE 182
        if units:
            # SOURCE LINE 183
            __M_writer(u'    ')
            __M_writer(escape(h.select(name='integerRestrictors-%s.unit'%(index), selected_values='', options=units, tabindex=8)))
            __M_writer(u'\n')
            pass
        # SOURCE LINE 185
        __M_writer(u'</li>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchFilter(context,locations,containsNots,allAnyOfs,options,index):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        range = context.get('range', UNDEFINED)
        len = context.get('len', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 148
        __M_writer(u'\n<li>\n  ')
        # SOURCE LINE 150
        __M_writer(escape(h.select(name='restrictors-%s.location'%(index), selected_values='', options=locations, tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 151
        __M_writer(escape(h.select(name='restrictors-%s.containsNot'%(index), selected_values='', options=containsNots, tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 152
        __M_writer(escape(h.select(name='restrictors-%s.allAnyOf'%(index), selected_values='', options=allAnyOfs, tabindex=8)))
        __M_writer(u'\n  <ul id="keywords_list" class="checklistBig">\n')
        # SOURCE LINE 154
        for i in range(len(options)): 
            # SOURCE LINE 155
            __M_writer(u"   <li>\n    <label for='")
            # SOURCE LINE 156
            __M_writer(escape("restrictors-%s.options-%s"%(index,i)))
            __M_writer(u"'><input id='")
            __M_writer(escape("restrictors-%s.options-%s"%(index,i)))
            __M_writer(u"' name='")
            __M_writer(escape("restrictors-%s.options-%s"%(index,i)))
            __M_writer(u'\' type="checkbox" value="')
            __M_writer(escape(options[i][0]))
            __M_writer(u'" tabindex=8 /> ')
            __M_writer(escape(options[i][1]))
            __M_writer(u'</label>\n   </li>\n')
            pass
        # SOURCE LINE 159
        __M_writer(u'  </ul>\n</li>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_fileSearchFields(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 8
        __M_writer(u'\n ')
        # SOURCE LINE 9
        __M_writer(escape(self.searchExpressions('file')))
        __M_writer(u'\n ')
        # SOURCE LINE 10
        __M_writer(escape(self.orderBy(app_globals.searchLocations['file'])))
        __M_writer(u'\n ')
        # SOURCE LINE 11
        __M_writer(escape(self.additionalFileSearchFilters()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_dictionarySearch(context):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 202
        __M_writer(u'\n ')
        # SOURCE LINE 203

        choices = [
            (
                'ol',        
                '%s to %s' % (app_globals.objectLanguageName,
                app_globals.metaLanguageName)
            ),
            (
                'ml',
                '%s to %s' % (app_globals.metaLanguageName,
                app_globals.objectLanguageName)
            )            
        ]
         
        
        # SOURCE LINE 216
        __M_writer(u'\n  ')
        # SOURCE LINE 217
        __M_writer(escape(h.text(name='dictionarySearchTerm', size='40', tabindex=1)))
        __M_writer(u'\n  ')
        # SOURCE LINE 218
        __M_writer(escape(h.select(name='dictionarySearchType', selected_values="", options=choices, tabindex=2)))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchFiltersFooter(context):
    context.caller_stack._push_frame()
    try:
        __M_writer = context.writer()
        # SOURCE LINE 140
        __M_writer(u'\n </ol>\n </fieldset>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_additionalFormSearchFilters(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 51
        __M_writer(u'\n ')
        # SOURCE LINE 55
        __M_writer(u'\n <!--HEADER-->\n ')
        # SOURCE LINE 57
        __M_writer(escape(self.searchFiltersHeader()))
        __M_writer(u'\n <!--FILTERS-->\n ')
        # SOURCE LINE 59
        __M_writer(escape(self.searchFilter(['speaker'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.speakers, 1)))
        __M_writer(u'\n ')
        # SOURCE LINE 60
        __M_writer(escape(self.searchFilter(['elicitor', 'enterer', 'verifier'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.users, 2)))
        __M_writer(u'\n ')
        # SOURCE LINE 61
        __M_writer(escape(self.searchFilter(['source'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.sources, 3)))
        __M_writer(u'\n ')
        # SOURCE LINE 62
        __M_writer(escape(self.searchFilter([('grammaticality', 'grammaticality')], ['is', 'is not'], ['any of'], [(None, 'empty'), ('*', '*'), ('?', '?')], 4)))
        __M_writer(u'\n ')
        # SOURCE LINE 63
        __M_writer(escape(self.searchFilter([('glossGrammaticality', 'gloss grammaticality')], ['contains', 'does not contain'], ['all of', 'any of'], [(None, 'empty'), ('*', '*'), ('?', '?')], 5)))
        __M_writer(u'\n ')
        # SOURCE LINE 64
        __M_writer(escape(self.searchFilter([('elicitationMethod', 'elicitation method')], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.elicitationMethods, 6)))
        __M_writer(u'\n ')
        # SOURCE LINE 65
        __M_writer(escape(self.searchFilter([('syntacticCategory', 'syntactic category')], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.syncats, 7)))
        __M_writer(u'\n ')
        # SOURCE LINE 66
        __M_writer(escape(self.searchFilter(['keywords'], ['contains', 'does not contain'], ['all of', 'any of'], [(None, 'empty')] + app_globals.keywords, 8)))
        __M_writer(u'\n <!--DATE FILTERS-->\n ')
        # SOURCE LINE 68
        __M_writer(escape(self.searchDateFilter(0)))
        __M_writer(u'\n ')
        # SOURCE LINE 69
        __M_writer(escape(self.searchDateFilter(1)))
        __M_writer(u'\n ')
        # SOURCE LINE 70
        __M_writer(escape(self.searchDateFilter(2)))
        __M_writer(u'\n ')
        # SOURCE LINE 71
        __M_writer(escape(self.searchDateFilter(3)))
        __M_writer(u'\n <!--FOOTER-->\n ')
        # SOURCE LINE 73
        __M_writer(escape(self.searchFiltersFooter()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_additionalFileSearchFilters(context):
    context.caller_stack._push_frame()
    try:
        sorted = context.get('sorted', UNDEFINED)
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        key = context.get('key', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 78
        __M_writer(u'\n ')
        # SOURCE LINE 82
        __M_writer(u'\n <!--HEADER-->\n ')
        # SOURCE LINE 84
        __M_writer(escape(self.searchFiltersHeader()))
        __M_writer(u'\n <!--FILTERS-->\n ')
        # SOURCE LINE 86
        __M_writer(escape(self.searchFilter([('MIMEtype', 'MIME type')], ['is', 'is not'], ['any of'], [(None, 'empty')] + [('"' + key + '"', key) for key in sorted(app_globals.allowedFileTypes.keys())], 1)))
        __M_writer(u'\n ')
        # SOURCE LINE 87
        __M_writer(escape(self.searchFilter(['elicitor', 'enterer'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.users, 2)))
        __M_writer(u'\n ')
        # SOURCE LINE 88
        __M_writer(escape(self.searchFilter(['speaker'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.speakers, 3)))
        __M_writer(u'\n ')
        # SOURCE LINE 89
        __M_writer(escape(self.searchFilter([('utteranceType', 'utterance type')], ['is', 'is not'], ['any of'], [(None, 'empty'), ('Object Language Utterance', 'Object Language Utterance'), ('Metalanguage Utterance', 'Metalanguage Utterance'), ('Mixed Utterance', 'Mixed Utterance')], 4)))
        __M_writer(u'\n <!--DATE FILTERS-->\n ')
        # SOURCE LINE 91
        __M_writer(escape(self.searchDateFilter(0)))
        __M_writer(u'\n ')
        # SOURCE LINE 92
        __M_writer(escape(self.searchDateFilter(1)))
        __M_writer(u'\n ')
        # SOURCE LINE 93
        __M_writer(escape(self.searchDateFilter(2)))
        __M_writer(u'\n ')
        # SOURCE LINE 94
        __M_writer(escape(self.searchDateFilter(3)))
        __M_writer(u'\n <!--INTEGER FILTERS-->\n ')
        # SOURCE LINE 96
        __M_writer(escape(self.searchIntegerFilter('file', 0, ['', 'bytes', 'KB', 'MB', 'GB'])))
        __M_writer(u'\n <!--FOOTER-->\n ')
        # SOURCE LINE 98
        __M_writer(escape(self.searchFiltersFooter()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchFiltersHeader(context):
    context.caller_stack._push_frame()
    try:
        c = context.get('c', UNDEFINED)
        hasattr = context.get('hasattr', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 125
        __M_writer(u'\n <fieldset>\n <!--By default the additional filters are hidden; but they may be visible\n if we are re-searching a previous search, in which case c.viewRestrictors\n will be True-->\n')
        # SOURCE LINE 130
        if hasattr(c, 'viewRestrictors') and c.viewRestrictors:
            # SOURCE LINE 131
            __M_writer(u' <legend>Additional Search Filters <a class="buttonLink" id="addRemoveASF" tabindex=8 onclick="addRemoveElement(\'additionalSearchFilters\',\'addRemoveASF\')">-</a></legend> \n <ol id="additionalSearchFilters" class="additionalSearchFilters" style="display:block;visibility:visible;">\n')
            # SOURCE LINE 133
        else:
            # SOURCE LINE 134
            __M_writer(u' <legend>Additional Search Filters <a class="buttonLink" id="addRemoveASF" tabindex=8 onclick="addRemoveElement(\'additionalSearchFilters\',\'addRemoveASF\')">+</a></legend>\n <ol id="additionalSearchFilters" class="additionalSearchFilters">\n')
            pass
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_collectionSearchFields(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 15
        __M_writer(u'\n ')
        # SOURCE LINE 16
        __M_writer(escape(self.searchExpressions('collection')))
        __M_writer(u'\n ')
        # SOURCE LINE 17
        __M_writer(escape(self.orderBy(app_globals.searchLocations['collection'])))
        __M_writer(u'\n ')
        # SOURCE LINE 18
        __M_writer(escape(self.additionalCollectionSearchFilters()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchExpressions(context,entity):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 24
        __M_writer(u'\n<fieldset>\n<legend>Search Expression 1</legend>\n<ol>\n <li>\n  ')
        # SOURCE LINE 29
        __M_writer(escape(h.text(name='searchTerm1', tabindex=1)))
        __M_writer(u'\n  ')
        # SOURCE LINE 30
        __M_writer(escape(h.select(name='searchType1', selected_values="", options=app_globals.searchTypes, tabindex=2)))
        __M_writer(u'\n  ')
        # SOURCE LINE 31
        __M_writer(escape(h.select(name='searchLocation1', selected_values="transcription", options=app_globals.searchLocations[entity], tabindex=3)))
        __M_writer(u'\n </li>\n</ol>\n</fieldset>\n<div id="andOrNotOL">\n  ')
        # SOURCE LINE 36
        __M_writer(escape(h.select(name='andOrNot', selected_values="and", options=app_globals.andOrNot, tabindex=4)))
        __M_writer(u'\n</div>\n<fieldset>\n<legend>Search Expression 2</legend>\n<ol>\n <li>\n  ')
        # SOURCE LINE 42
        __M_writer(escape(h.text(name='searchTerm2', tabindex=5)))
        __M_writer(u'\n  ')
        # SOURCE LINE 43
        __M_writer(escape(h.select(name='searchType2', selected_values="", options=app_globals.searchTypes, tabindex=6)))
        __M_writer(u'\n  ')
        # SOURCE LINE 44
        __M_writer(escape(h.select(name='searchLocation2', selected_values="gloss", options=app_globals.searchLocations[entity], tabindex=7)))
        __M_writer(u'\n </li>\n</ol>\n</fieldset>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_searchDateFilter(context,index):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 165
        __M_writer(u'\n<li>\n  ')
        # SOURCE LINE 167
        __M_writer(escape(h.select(name='dateRestrictors-%s.location'%(index), selected_values='', options=[('dateElicited', 'date elicited'), ('datetimeEntered', 'date entered'), ('datetimeModified', 'date modified')], tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 168
        __M_writer(escape(h.select(name='dateRestrictors-%s.relation'%(index), selected_values='', options=[('', 'is'), ('not_', 'is not'), ('earlier_than', 'is earlier than'), ('later_than', 'is later than')], tabindex=8)))
        __M_writer(u'\n  ')
        # SOURCE LINE 169
        __M_writer(escape(h.text(name='dateRestrictors-%s.date'%(index), size='10', maxlength='10', tabindex=8)))
        __M_writer(u'\n  (mm/dd/yyyy)\n</li>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_additionalCollectionSearchFilters(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        app_globals = context.get('app_globals', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 102
        __M_writer(u'\n ')
        # SOURCE LINE 106
        __M_writer(u'\n <!--HEADER-->\n ')
        # SOURCE LINE 108
        __M_writer(escape(self.searchFiltersHeader()))
        __M_writer(u'\n <!--FILTERS-->\n ')
        # SOURCE LINE 110
        __M_writer(escape(self.searchFilter(['elicitor', 'enterer'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.users, 0)))
        __M_writer(u'\n ')
        # SOURCE LINE 111
        __M_writer(escape(self.searchFilter(['speaker'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.speakers, 1)))
        __M_writer(u'\n ')
        # SOURCE LINE 112
        __M_writer(escape(self.searchFilter(['source'], ['is', 'is not'], ['any of'], [(None, 'empty')] + app_globals.sources, 2)))
        __M_writer(u'\n <!--DATE FILTERS-->\n ')
        # SOURCE LINE 114
        __M_writer(escape(self.searchDateFilter(0)))
        __M_writer(u'\n ')
        # SOURCE LINE 115
        __M_writer(escape(self.searchDateFilter(1)))
        __M_writer(u'\n ')
        # SOURCE LINE 116
        __M_writer(escape(self.searchDateFilter(2)))
        __M_writer(u'\n ')
        # SOURCE LINE 117
        __M_writer(escape(self.searchDateFilter(3)))
        __M_writer(u'\n <!--INTEGER FILTERS-->\n ')
        # SOURCE LINE 119
        __M_writer(escape(self.searchIntegerFilter('collection', 0)))
        __M_writer(u'\n <!--FOOTER-->\n ')
        # SOURCE LINE 121
        __M_writer(escape(self.searchFiltersFooter()))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


